﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;

namespace SourceStack.Entities
{
    public class User : Entity
    {
        [Display(Name = "用户名")]
        [Required(ErrorMessage ="用户名不能为空",AllowEmptyStrings =true)]
        public string Name { get; set; }
        public bool IsMale { get; set; }

        public string ValidationCode { get; set; }
        public string SelfDescription { get; set; }
        public User InvitedBy { get; set; }
        [MinLength(4,ErrorMessage ="* 密码不能少于4个字符")]
        public string Password { get; set; }
        public int BCredit { get; set; }
        [StringLength(4,MinimumLength =4,ErrorMessage ="* 长度只能为4")]
        public string InviteCode { get; set; }
        [Compare(nameof(Password), ErrorMessage = "两次输入密码不一致")]
        public string ConfirmPassword { get; set; }
        public void Register( User newuser)
        {
            newuser.InvitedBy.BCredit += 10;
        }

    }
}
